/*
 * CirclePanel.java
 *
 * 
 */
package it.luigiarpino.alt2jsim.netpanel.flat;


import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import java.awt.Color;
/**
 *
 * @author  Luigi Lorenzo Arpino 534/559
 */
public class NetPanel extends JPanel{
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 2834973254162676989L;
	private CirclePanel pannelloCircolare;
    private JComboBox combo;
    private JLabel etichetta;
    private JLabel titolo;
    private JPanel northPanel;
    private JPanel southPanel;
    private JPanel centerPanel;
    
     /**Mostra nodi come reti di terzo livello*/
    public static final int LEVEL2NET=2;
    /** Mostra nodi come reti di secondo livello */
    public static final int LEVEL1NET=1;
    /**Mostra nodi router*/
    public static final int ROUTER=3;
    /**Mostra nodi transit*/
    public static final int TRANSIT_NODE=4;
    /**Mostra nodi come reti transit*/
    public static final int TRANSIT_NET=5;
    

    //** Visualizza un pannello con la rappresentazione della rete*/
    public  NetPanel(int[][] link_ ,String titolo_,String[] nomiNodi_, int image) {
        super();
        try { 
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());     
    	} 
    	catch(Exception e) { }
        if (link_==null){
            return;
        }
        if (nomiNodi_==null){
            nomiNodi_=new String[link_.length];
            for(int i=0;i<link_.length;i++){
                nomiNodi_[i]=String.valueOf(i);
            }
        }
        this.setLayout(new BorderLayout());
        combo=new JComboBox();
        int numLink_=link_.length;
        String[] numeri=new String[numLink_];
        for (int i=0;i<numLink_;i++){
            numeri[i]="  "+nomiNodi_[i]+"  ";
        }
        combo.setModel(new javax.swing.DefaultComboBoxModel(numeri));
        combo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboActionPerformed(evt);
            }
        });
        etichetta =new JLabel("Highlight the nodes adjacent to the number");
        northPanel=new JPanel();
        southPanel=new JPanel();
        this.southPanel.setLayout(new java.awt.FlowLayout());
        this.southPanel.add(this.etichetta);
        this.southPanel.add(this.combo);
        this.southPanel.setBackground(Color.WHITE);
        this.pannelloCircolare=new CirclePanel(link_, numLink_,nomiNodi_,image);
        titolo_=titolo_+ " formed by "+nomiNodi_.length+" nodes";
        this.titolo=new JLabel(titolo_);
        this.northPanel.setLayout(new java.awt.FlowLayout());
        this.northPanel.add(this.titolo);
        this.northPanel.setBackground(Color.WHITE);
        this.centerPanel=new JPanel();
        this.centerPanel.setBackground(Color.WHITE);
        this.centerPanel.setLayout(new BorderLayout());
        this.centerPanel.add(this.pannelloCircolare,BorderLayout.CENTER);
        this.add(this.northPanel,BorderLayout.NORTH);
        this.add(this.southPanel,BorderLayout.SOUTH);
        this.add(this.centerPanel,BorderLayout.CENTER);
    }
    
     private void ComboActionPerformed(java.awt.event.ActionEvent evt) {
         this.pannelloCircolare.showNetwork(this.combo.getSelectedIndex());
    }
    
}
